#####################################################
# Makefile: Makefile for Assignment3 EECS22 Fall2011
#
# 10/10/11 Weiwei Chen: initial solution version                  
#
#####################################################

# design names
D=out
CC = gcc
OPT = -ansi -Wall -g
#DEBUG = -DDEBUG

all: Disassemble FileReader
D: Disassemble
F: FileReader
Hex: HexConverter

#target to generate DecodedStructs.o
DecodedStructs.o: DecodedStructs.h DecodedStructs.c 
	gcc -c DecodedStructs.c -o DecodedStructs.o $(OPT)

HexConverter: 
	gcc -c HexConverter.c -o Hex $(OPT)

#target to generate disassembler.o
disassembler.o: disassembler.h disassembler.c
	gcc -c disassembler.c -o disassembler.o $(OPT)

#target to generate format.o
format.o: format.h format.c 
	gcc -c format.c -o format.o $(OPT)

#target to generate FileReader.o
FileReader.o: FileReader.h FileReader.c
	gcc -c FileReader.c -o FileReader.o $(OPT)

#target to generate FileReader.o
FileReader2.o: FileReader.h FileReaderwMain.c
	gcc -c FileReaderwMain.c -o FileReader2.o $(OPT)

#target to generate Disassemble.o
Disassemble.o: Disassemble.c
	gcc -c Disassemble.c -o Disassemble.o $(OPT)

#target to generate Disassemble
Disassemble: FileReader.o DecodedStructs.o disassembler.o format.o Disassemble.o 
	gcc FileReader.o DecodedStructs.o disassembler.o format.o Disassemble.o -o Disassemble $(OPT)

#target to generate FileReader
FileReader: DecodedStructs.o disassembler.o format.o FileReader2.o  
	gcc DecodedStructs.o disassembler.o format.o FileReader2.o -o MIPS $(OPT)



memcheck: Disassemble
	valgrind --leak-check=full ./Disassemble
	
#target to clean the directory
clean:
	rm -f *.o *.asm *.asci Disassemble MIPS Hex test.txt
